import java.util.Scanner;


public class Test5 {
    static int N = 1010;

    //n：表示物品数量；v表示背包体积
    public static int packBag(int n,int v,int[] vla,int[] V){
        //1.创建dp表
        int[][] dp = new int[N][N];
        //2.开始填表
        for(int i = 1;i <= n;i++){
            for(int j = 0;j <= v;j++){
                dp[i][j] = dp[i - 1][j];
                if(j >= V[i - 1])
                    dp[i][j] = Math.max(dp[i - 1][j],dp[i - 1][j - V[i - 1]] + vla[i - 1]);
            }

        }
        return dp[n][v];
    }

    public static void main(String[] args) {
        //1.先输入物品数量和背包的体积
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int v = scanner.nextInt();

        int w[] = {2,2,6,5,4};
        int v1[] = {6,3,5,4,6};
        //2.调用方法
        int max = packBag(n,v,v1,w);
        System.out.println(max);
    }

}
